<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.wxtf.platform.plugins.user.*"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
	UserBean user = (UserBean)request.getSession().getAttribute("userBean");
	String _db = user.getDbType();
	Map<String,List<Map<String, String>>> dicMap = user.getDicMap();
	Map<String, String> surMap = user.getGlobalMap();
	String surTime=surMap.get("surTime");
	List<Map<String, String>> list = null;
	List<Map<String, String>> list1 = null;
	String temp = "";
	String tbe_employment_forms = "";//用工形式
	String tbe_marital_status = "";//婚姻状态
	String tbe_marital_condition = "";//婚姻状况
	String tbe_ba_status = "";//生育能力状态
	String tbe_birth_control_measures = "";//节育措施
	String tbe_es_reason="";//重点理由
	String tbcsr_type="";//手术类型
	String tbcsr_type_="";//妊娠失败
	String sr_type="";
	list = dicMap.get("101");
	if(null != list && list.size() > 0){
		for(Map<String, String> map: list){
			tbe_employment_forms += "<option value=\"" + map.get("tmgd_id")+"\">" + map.get("tmgd_name") + "</option>";
		}
	}
	list = null;
	list = dicMap.get("27");
	if(null != list && list.size() > 0){
		for(Map<String, String> map: list){
			tbe_marital_status += "<option value=\"" + map.get("tmgd_id")+"\">" + map.get("tmgd_name") + "</option>";
		}
	}
	list = null;
	list = dicMap.get("7");
	if(null != list && list.size() > 0){
		for(Map<String, String> map: list){
			tbe_marital_condition += "<option value=\"" + map.get("tmgd_id")+"\">" + map.get("tmgd_name") + "</option>";
		}
	}
	list = null;
	list = dicMap.get("103");
	if(null != list && list.size() > 0){
		for(Map<String, String> map: list){
			tbe_ba_status += "<option value=\"" + map.get("tmgd_id")+"\">" + map.get("tmgd_name") + "</option>";
		}
	}
	list = null;
	list = dicMap.get("104");
	if(null != list && list.size() > 0){
		for(Map<String, String> map: list){
			tbe_birth_control_measures += "<option value=\"" + map.get("tmgd_id")+"\">" + map.get("tmgd_name") + "</option>";
		}
	}
	list = null;
	list = dicMap.get("107");
	if(null != list && list.size() > 0){
		for(Map<String, String> map: list){
			tbe_es_reason += "<option value=\"" + map.get("tmgd_id")+"\">" + map.get("tmgd_name") + "</option>";
		}
	}
	list = null;
	list = dicMap.get("109");
	if(null != list && list.size() > 0){
		for(Map<String, String> map: list){
			tbcsr_type += "<option value=\"" + map.get("tmgd_id")+"\">" + map.get("tmgd_name") + "</option>";
		}
	}
	
	list = null;
	list = dicMap.get("110");
	if(null != list && list.size() > 0){
		for(Map<String, String> map: list){
			tbcsr_type_ += "<option value=\"" + map.get("tmgd_id")+"\">" + map.get("tmgd_name") + "</option>";
		}
	}
	
	sr_type=tbcsr_type+tbcsr_type_;//将两种手术方式拼接
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
   <base href="<%=basePath%>"/>
   		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta http-equiv="pragma" content="no-cache"/>
		<meta http-equiv="cache-control" content="no-cache"/>
		<meta http-equiv="expires" content="0"/>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

		<link type="text/css" rel="stylesheet" href="ligerUI/skins/Aqua/css/ligerui-all.css" />
		<link type="text/css" rel="stylesheet" href="ligerUI/skins/<%=user.getUserCss()%>/css/ligerui-all.css" />
		<link type="text/css" rel="stylesheet" href="ligerUI/skins/ligerui-icons.css" />
		<link type="text/css" rel="stylesheet" href="resource/css/style.css" />

		<script type="text/javascript" src="js/jquery/jquery-1.7.2.js"></script>
		<script type="text/javascript" src="ligerUI/js/core/base.js"></script>
		<script type="text/javascript" src="ligerUI/js/ligerui.min.js"></script>
		<script type="text/javascript" src="js/common.js"></script>
		<script type="text/javascript" src="js/validata.js"></script>

		<script type="text/javascript" src="ligerUI/js/plugins/ligerGrid.js"></script>
		<script type="text/javascript" src="ligerUI/js/plugins/ligerTree.js"></script>
		<script type="text/javascript" src="ligerUI/js/plugins/ligerForm.js"></script>
		<script type="text/javascript" src="ligerUI/js/plugins/ligerDateEditor.js"></script>
		
		<script type="text/javascript" src="ligerUI/jquery-validation/jquery.validate.min.js" ></script> 
		<script type="text/javascript" src="ligerUI/jquery-validation/jquery.metadata.js"></script>
		<script type="text/javascript" src="ligerUI/jquery-validation/messages_cn.js" ></script>
		
<script type="text/javascript">
var _db = '<%=_db%>';
var surTime='<%= surTime%>';
var jsonObj={
    };
_jsonObj.classname = "com.wxtf.platform.main.surgery.SurgreyRecordAction";
_jsonObj.methodname = "queryPage_sur_vr";
_jsonObj.logicdata = "[{\"types\":\"init\"}]";
 var today = new Date();//获得系统当前时间
 var toMon = today.getMonth() + 1;
 var toDay = today.getDate();
var manager;//员工信息表格
var win_sur;//四术登记窗口
var manager_sur;//登记详细信息表格
var win_show;//登记详细信息窗口
var manager_emp;//人员信息表格
var win_emp;//人员信息窗口
var win_survr;//随访登记窗口
var win_survr_show;//随访详细窗口
$(function(){
	manager = $("#sur_grid").ligerGrid({
		url: _url, parms: _jsonObj, width: '100%', height: '100%',
		usePager: true, rownumbers: true, checkbox: true, alternatingRow: false,enabledSort: false,
		columns: [
			{ display: 'tbcsr_id', name: 'tbcsr_id', width:1,hide: true },
			{ display: 'tbe_id', name: 'tbe_id', hide: true,width:1 },
			{ display: 'org_id', name: 'org_id', hide: true,width:1 },
			{ display: '机构名称', name: 'org_name', width:130 },
			{ display: '姓名', name: 'tbe_name', width: 80, align: 'left' ,render: function(record, index, value, oth){
					return " <a href='javascript:showData(" + JSON.stringify(record) + ")'>"+value+"</a>";
				}},
			{ display: '性别', name: 'tbe_sex', width: 50 },
			{ display: '出生日期', name: 'tbe_birthday', width: 100},
			{ display: '年龄', name: 'tbe_age', hide: true,width:1 },
			{ display: '手机', name: 'tbe_mobile', width: 1, hide: true },
			{ display: '手术类型', name: 'tbcsr_type', width: 100,
				render: function(record, index, value, oth){
					<%
					list = dicMap.get("109");
					list1 = dicMap.get("110");
					temp = "";
					if(null != list && list.size() > 0){
						for(Map<String, String> map: list){
					%>
					if(value == '<%=map.get("tmgd_id")%>'){
						<%
						temp = map.get("tmgd_name");
						%>
						return '<%=temp%>';
					}
					<%
						}
					}
				
					if(null != list1 && list1.size() > 0){
						for(Map<String, String> map: list1){
					%>
					if(value == '<%=map.get("tmgd_id")%>'){
						<%
						temp = map.get("tmgd_name");
						%>
						return '<%=temp%>';
					}
					<%
						}
					}
					%>
					return value==0?"无":value;
				} },
			{ display: '手术时间', name: 'tbcsr_time', width: 90 },
			{ display: '随访时间', name: 'tbcsrvr_time', width: 100 },
			{ display: '随访人', name: 'caption', width: 100 },
			{ display: '家庭住址', name: 'tbe_address', width: 100 },
			{ display: '婚姻状态', name: 'tbe_marital_status', width: 100,
				render: function(record, index, value, oth){
					<%
					list = dicMap.get("27");
					temp = "";
					if(null != list && list.size() > 0){
						for(Map<String, String> map: list){
					%>
					if(value == '<%=map.get("tmgd_id")%>'){
						<%
						temp = map.get("tmgd_name");
						%>
						return '<%=temp%>';
					}
					<%
						}
					}
					%>
					return value;
				}
			},
			{ display: '随访登记', name:'edit',width:80,render: function(record, index, value, oth){
			        if(record.tbcsrvr_time==''||record.tbcsrvr_time==null){  
					return "<img src='ligerUI/skins/icons/page_edit.gif' onclick='addData_sur_vr(" + JSON.stringify(record) + ")'></img>";
					}else{
					 return "<img src='ligerUI/skins/icons/page_edit.gif' onclick='showData_sur_vr(" + JSON.stringify(record) + ")'></img>";
					}
				}
			}
		],
		toolbar: {
			items: [{ text: '登记', click: function(){ show_emp(); }, icon: 'add' },
					{ text: '删除', click: function(){ delData(); },icon: 'delete'}	]
			},
		rowAttrRender :function(record, index, value, oth){
		     var csrMou=record.tbcsr_time.substring(5,7);  
	         var mosun=Number(toMon)-Number(csrMou);
		     if(record.tbcsrvr_time==""||record.tbcsrvr_time==null){ 
                   if(Number(record.tbcsr_time.substring(0,4))==Number(new Date().getFullYear()) )
                   {     
                        if(mosun>1){   
							return "style='background-color:#ffcccc;'"; 
						}else if(mosun==1&&Number(toDay)>=Number(surTime)){
						 	return "style='background-color:#ffcccc;'"; 
						}
					}else if(Number(record.tbcsr_time.substring(0,4))<Number(new Date().getFullYear()) )
                   {
                       return "style='background-color:#ffcccc;'"; 
                   }
                   
			}  
		}
	});
	/*
	 * 日期框
	 */
	$("#tbcsr_time").ligerDateEditor({ format: "yyyy-MM-dd", width:180 });
	$("#tbcsrvr_time").ligerDateEditor({ format: "yyyy-MM-dd", width:180 });
	});
/**
*显示需要选择的用户
*/
var _jsonObj0 = {
		"classname": "com.wxtf.platform.main.surgery.SurgreyRecordAction",
		"methodname": "queryPage",
		"logicdata":"[{\"types\":\"init\"}]"
	};
function show_emp(){
win_emp=initWindowByDiv('show_emp', '选择人员', 800, 425,addData, closeWin);
manager_emp = $("#emp-grid").ligerGrid({
		url: _url, parms: _jsonObj0, width: '770', height: '300',
		usePager: true, rownumbers: true, checkbox: true, alternatingRow: true,
		columns: [
			{ display: 'tbe_id', name: 'tbe_id', hide: true,width:1 },
			{ display: 'org_id', name: 'org_id', hide: true,width:1 },
			{ display: '机构名称', name: 'reserve1', width:150, align:'left',isSort:false },
			{ display: '姓名', name: 'tbe_name', width: 100, align: 'left'},
			{ display: '性别', name: 'tbe_sex', width: 60, align: 'left' },
			{ display: '出生日期', name: 'tbe_birthday', width: 100, align: 'left' },
			{ display: '民族', name: 'tbe_nation', width:  1, hide:true },
			{ display: '身份证号', name: 'tbe_idcard', width: 180, align: 'left' },
			{ display: '婚姻状态', name: 'tbe_marital_status', width: 100, align: 'left',
				render: function(record, index, value, oth){
					<%
					list = dicMap.get("27");
					temp = "";
					if(null != list && list.size() > 0){
						for(Map<String, String> map: list){
					%>
					if(value == '<%=map.get("tmgd_id")%>'){
						<%
						temp = map.get("tmgd_name");
						%>
						return '<%=temp%>';
					}
					<%
						}
					}
					%>
					return value;
				}
			}
		]
	});
}

/*
 * 删除人员
 */
function delData(){
	var Ids = getIds();
	if(Ids == ""){
		warningTip('请至少选择一个用户进行操作');
		return;
	}
	$.ligerDialog.confirm('确定要删除选中的数据吗？（删除不可恢复）', function (opt) { 			
		if(opt){
			_jsonObj.methodname = "delete";
			_jsonObj.logicdata = "[{\"ids\":\"" + Ids + "\"}]";
			callserver(_jsonObj, function(data, textStatus){
				if(data.result || data.result == 'true'){
							succMsgTip(data.resultrecord);
						}else{
							warningTip(data.resultrecord);
						}
				}, function(data, textStatus){
			});
		}
		serch_all();
	});
	
}
/*
 * 获取列表ID
 */
function getIds(){
	var arrayUsers = manager.getSelecteds();
	if(arrayUsers.length == 0){
		return "";
	} else {
		var text = "";
		for(var i=0; i<arrayUsers.length; i++){
			text += arrayUsers[i].tbcsr_id + ",";
		}
		return text.substring(0, text.length - 1);
	}
}

/*
*打开信息登记窗口
*/
function addData(){
      
	  var row = manager_emp.getSelecteds();
			if(row.length != 1){
				warningTip('只能选择一个人员！');
				return;
			}else{
			  win_emp.hide();
			  document.getElementById('sur_add_form').reset();
			  $("#tbe_id").val(row[0].tbe_id);
			  $("#org_id").val(row[0].org_id);
			  
			  var yes_or_no = $(":radio[name='check_type']:checked").val();
			  if(yes_or_no==1||yes_or_no==0)
			  {document.getElementById("tbcsr_type_1").disabled=false;}
			  else
			  {document.getElementById("tbcsr_type_1").disabled=true;}
			  
			  if(win_sur==null){
			      var d = new Date();
				  var vYear = d.getFullYear();
				  var vMon = d.getMonth() + 1;
				  var vDay = d.getDate();
				  var now_time=vYear+"-"+vMon+"-"+vDay;
			     $("#tbcsr_time").val(now_time);
			     win_sur=initWindowByDiv('surAdd-div', '四术登记', 540, 340,save_sur,closeWin);
			  }else{
			     win_sur.show();
			  }
	 }
}
/*
*四术信息登记
**/
function save_sur(){
   var yes_or_no = $(":radio[name='check_type']:checked").val();
   var tbcsr_hospital = $("#tbcsr_hospital").val();
   var tbcsr_place = $("#tbcsr_place").val();
   var tbcsr_doctor = $("#tbcsr_doctor").val();
   var tbcsr_time = $("#tbcsr_time").val();
   var tbcsr_description=$("#tbcsr_description").val();
   var tbcsr_memo=$("#tbcsr_memo").val();
   if(!checkIsString(tbcsr_hospital)){
		warningTip("手术医院：必须为字母、数字、下划线、中文组成");
		return ;
	}
	if(fucCheckLength(tbcsr_hospital) > 64){
		warningTip('手术医院：不能超过64字符');
		return ;
	}
	if(!checkIsString(tbcsr_place)){
		warningTip("手术地点：必须为字母、数字、下划线、中文组成");
		return ;
	}
	if(fucCheckLength(tbcsr_place) > 64){
		warningTip('手术地点：不能超过64字符');
		return ;
	}
	if(!checkIsString(tbcsr_doctor)){
		warningTip("手术医生：必须为字母、数字、下划线、中文组成");
		return ;
	}
	if(fucCheckLength(tbcsr_doctor) > 32){
		warningTip('手术医生：不能超过32字符');
		return ;
	}
	
	if(!checkIsString(tbcsr_description)){
		warningTip("术后状况：必须为字母、数字、下划线、中文组成");
		return ;
	}
	if(fucCheckLength(tbcsr_description) > 512){
		warningTip('术后状况：不能超过512字符');
		return ;
	}
	if(!checkIsString(tbcsr_memo)){
		warningTip("备注：必须为字母、数字、下划线、中文组成");
		return ;
	}
	if(fucCheckLength(tbcsr_memo) > 512){
		warningTip('备注：不能超过512字符');
		return ;
	}
   
	   _jsonObj.methodname = "save";
	   _jsonObj.logicdata = getForm("sur_add_form");
	   if(yes_or_no==1||yes_or_no==0)
		{
			if(beforeSub(tbcsr_hospital,tbcsr_place,tbcsr_doctor,tbcsr_time))
			{callserver(_jsonObj, ajaxCallbackSuccFunc, ajaxCallbackErrorFunc);}
		}
	   else {warningTip("请选择手术类型！");}
}
//登记前验证
function beforeSub(tbcsr_hospital,tbcsr_place,tbcsr_doctor,tbcsr_time)
{
	var fin_val=1;
	var tip="";
  	if(tbcsr_hospital==""||tbcsr_hospital==null){tip+="[手术医院]";}
  	if(tbcsr_place==""||tbcsr_place==null){tip+="[手术地点]";}
  	if(tbcsr_doctor==""||tbcsr_doctor==null){tip+="[手术医生]";}
  	if(tbcsr_time==""||tbcsr_time==null){tip+="[手术时间]";}
  	if(tip!=""){warningTip("请输入"+tip+"！"); fin_val=0;}
	return fin_val;
}
/*
*随访信息登记窗口
*/
function addData_sur_vr(row){
      var d = new Date();
	  var vYear = d.getFullYear();
	  var vMon = d.getMonth() + 1;
	  var vDay = d.getDate();
	  var now_time=vYear+"-"+vMon+"-"+vDay
	  document.getElementById('survr_add_form').reset();
	  $("#tbcsr_id_vr").val(row.tbcsr_id);
	  $("#tbe_id_vr").val(row.tbe_id);
	  $("#tbe_name").val(row.tbe_name);
	  $("#tbcsrvr_time").val(now_time);
	  $("#tbcsr_description_vr").val(row.tbcsr_description);
	  $("#tbcsr_time_vr").val(row.tbcsr_time);
	 
	  if(win_survr==null){
	     win_survr=initWindowByDiv('survrAdd-div', '随访登记', 590, 230,save_vr, closeWin);
	  }else{
	     win_survr.show();
	  }
	 
}
/*
*随访信息登记
**/
function save_vr(){
    var tbcsrvr_surgery_before = $("#tbcsrvr_surgery_before").val();
    var tbcsrvr_surgery_after = $("#tbcsrvr_surgery_after").val();
    var tbcsrvr_time = $("#tbcsrvr_time").val();
	
	var tbcsrvr_emmenia = $("#tbcsrvr_emmenia").val();//月经情况
	var tbcsrvr_offer = $("#tbcsrvr_offer").val();//产后避孕
	   
	   if(!checkIsString(tbcsrvr_surgery_before)){
			warningTip("术前避孕：必须为字母、数字、下划线、中文组成");
			return ;
		}
	   if(fucCheckLength(tbcsrvr_surgery_before) > 32){
			warningTip('术前避孕：不能超过32字符');
			return ;
		}
		if(!checkIsString(tbcsrvr_surgery_after)){
			warningTip("术后避孕：必须为字母、数字、下划线、中文组成");
			return ;
		}
	    if(fucCheckLength(tbcsrvr_surgery_after) > 32){
			warningTip('术后避孕：不能超过32字符');
			return ;
		}
		if(!checkIsString(tbcsrvr_emmenia)){
			warningTip("月经情况：必须为字母、数字、下划线、中文组成");
			return ;
		}
	    if(fucCheckLength(tbcsrvr_emmenia) > 256){
			warningTip('月经情况：不能超过256字符');
			return ;
		}
		if(!checkIsString(tbcsrvr_offer)){
			warningTip("产后避孕：必须为字母、数字、下划线、中文组成");
			return ;
		}
	    if(fucCheckLength(tbcsrvr_offer) > 256){
			warningTip('产后避孕：不能超过256字符');
			return ;
		}
		
	   _jsonObj.methodname = "save_vr";
	   _jsonObj.logicdata = getForm("survr_add_form");
	   if(suifang_beforeSub(tbcsrvr_surgery_before,tbcsrvr_surgery_after,tbcsrvr_time))
	   {callserver(_jsonObj, ajaxCallbackSuccFunc_vr, ajaxCallbackErrorFunc);} 
}
//随访登记前验证
function suifang_beforeSub(tbcsrvr_surgery_before,tbcsrvr_surgery_after,tbcsrvr_time)
{
	var fin_val=1;
	var tip="";
  	if(tbcsrvr_time==""||tbcsrvr_time==null){tip+="[随访时间]";}
  	if(tbcsrvr_surgery_before==""||tbcsrvr_surgery_before==null){tip+="[术前避孕]";}
  	if(tbcsrvr_surgery_after==""||tbcsrvr_surgery_after==null){tip+="[术后避孕]";}
  	if(tip!=""){warningTip("请输入"+tip+"！"); fin_val=0;}
  	return fin_val;
}
/*
*随访信息详细
*/
function showData_sur_vr(row){
      document.getElementById('survr_add_form').reset();
	  $("#tbcsr_id_vr").val(row.tbcsr_id);
	  $("#tbe_id_vr").val(row.tbe_id);
	  $("#tbe_name").val(row.tbe_name);
	  $("#tbcsrvr_time").val(row.tbcsrvr_time);
	  $("#tbcsr_description_vr").val(row.tbcsr_description);
	  $("#tbcsr_time_vr").val(row.tbcsr_time);
	  $("#tbcsrvr_surgery_before").val(row.tbcsrvr_surgery_before);
	  $("#tbcsrvr_surgery_after").val(row.tbcsrvr_surgery_after);
	  $("#tbcsrvr_emmenia").val(row.tbcsrvr_emmenia);
	  $("#tbcsrvr_offer").val(row.tbcsrvr_offer);
	  if(win_survr==null){
	     win_survr_show=initWindowByDiv('survrAdd-div', '随访详细信息', 590, 230,save_vr,closeWin); 
	  }else{
	     win_survr.show();
	  }
}
/*
*四术登记详细信息
*/

function showData(row){
    
    var tbe_id=row.tbe_id;
	var _jsonObj0 = {
		"classname":"com.wxtf.platform.main.surgery.SurgreyRecordAction",
		"methodname":"queryPage_sur",
		"logicdata":"[{\"types\":\"init\",\"tbe_id\":\""+tbe_id+"\"}]"
	};
   if(win_show==null){
	     win_show=initWindowByDiv2('sur_show_grid', '四术信息明细', 950,450,closeWin_);
	 }else{
	   win_show.show();
	 }
    manager_sur=$("#sur_show_grid").ligerGrid({
		url: _url, parms: _jsonObj0, width: '900', height: '380',
		usePager: true, rownumbers: true,alternatingRow: true,
		columns: [
			{ display: '姓名', name: 'tbe_name', width: 80, align: 'left'},
			{ display: '手术类型', name: 'tbcsr_type', width: 100, align: 'left',
				render: function(record, index, value, oth){
					<%
					list = dicMap.get("109");
					list1 = dicMap.get("110");
					temp = "";
					if(null != list && list.size() > 0){
						for(Map<String, String> map: list){
					%>
					if(value == '<%=map.get("tmgd_id")%>'){
						<%
						temp = map.get("tmgd_name");
						%>
						return '<%=temp%>';
					}
					<%
						}
					}
				
					if(null != list1 && list1.size() > 0){
						for(Map<String, String> map: list1){
					%>
					if(value == '<%=map.get("tmgd_id")%>'){
						<%
						temp = map.get("tmgd_name");
						%>
						return '<%=temp%>';
					}
					<%
						}
					}
					%>
					return value==0?"无":value;
				} },
			{ display: '手术地点', name: 'tbcsr_place', width: 100, align: 'left' },
			{ display: '手术医院', name: 'tbcsr_hospital',width: 100, align: 'left'},
			{ display: '手术医生', name: 'tbcsr_doctor',width: 100, align: 'left'},
			{ display: '手术时间', name: 'tbcsr_time',width: 100, align: 'left'},
			{ display: '手术情况', name: 'tbcsr_description',width: 150, align: 'left'},
			{ display: '备注', name: 'tbcsr_memo', width:150, align:'left' }
			]
			});
}

/*
 * 导出
 */
function expData(){
	var orgIds = $('#org2').val();
	var tbcsr_type = $('#ser3').val();
	var tbe_name = $('#ser1').val().trim();
	var tbe_idcard = $('#ser4').val().trim();
	
	_jsonObj.methodname = "expData";
	_jsonObj.logicdata = '[{\"orgIds\":\"' + orgIds + '\",\"tbcsr_type\":\"' + tbcsr_type
			+ '\",\"tbe_name\":\"' + tbe_name + '\",\"tbe_idcard\":\"' + tbe_idcard + '\"}]';
	
	callserver(_jsonObj, function(data, textStatus){
		if(data.result){
			downloadFile(data.resultrecord);
		} else {
			warningTip(data.resultrecord);
		}
	}, function(data, textStatus){
	});
}

//隐藏窗口
function closeWin_(item, dialog) {
	win_show.hide();
	manager_sur.loadData();
}
/*
 * ajax成功回调
 */
function ajaxCallbackSuccFunc(data, textStatus){
	serch_all();
	succMsgTip(data.resultrecord);
	if(win_sur&&data.result){
		win_sur.hide();
	}
	
}
function ajaxCallbackSuccFunc_vr(data, textStatus){
	serch_all();
	succMsgTip(data.resultrecord);
	if(win_survr&&data.result){
		win_survr.hide();
	}
	
}
/*
 * ajax失败回调
 */
function ajaxCallbackErrorFunc(data, textStatus){
	warningTip(data.resultrecord);
}
/*
 * 条件查询
 */

function serch2(){
	var orgIds = $('#org2').val();
	var tbcsr_type = $('#ser3').val();
	var tbe_name = $('#ser1').val();
	var tbe_idcard = $('#ser4').val();
	
	_jsonObj.methodname = "queryPage_sur_vr";
	_jsonObj.logicdata = '[{\"orgIds\":\"' + orgIds + '\",\"tbcsr_type\":\"' + tbcsr_type
			+ '\",\"tbe_name\":\"' + tbe_name + '\",\"tbe_idcard\":\"' + tbe_idcard + '\",\"types\":\"serch1\"}]';
	manager.loadData();
}
function serch3(){
	var orgIds = $('#org3').val();
	var tbe_name = $('#name3').val();
	var tbe_idcard = $('#card3').val();
	_jsonObj0.methodname = "queryPage";
	_jsonObj0.logicdata = '[{\"orgIds\":\"' + orgIds + '\",\"tbe_name\":\"' + tbe_name + '\",\"tbe_idcard\":\"'
	                      + tbe_idcard + '\",\"types\":\"serch1\"}]';
	manager_emp.loadData();
}
function serch_all(){
	_jsonObj.methodname = "queryPage_sur_vr";
	_jsonObj.logicdata = '[{\"types\":\"init\"}]';
	manager.loadData();
}
/*
*选择四术还是妊娠失败的判断
*/

function select_type(type){
   var type_se1 = $("#tbcsr_type_1");
       if(type=='1'){
	      document.getElementById("tbcsr_type_1").disabled=false;
	     // type_se1.empty();
	     $("#tbcsr_type").val($("#tbcsr_type_1").val());
	   }
}
  </script>
  </head>
  <body>
  <table class="serTable">
			<tr>
				<td>
					组织机构：<select id="org2" style=" width: 152px;">
						<%=user.getCurSubOrgOptions()%>
					</select>
				</td>
				<td>姓名：<input id="ser1" style=" width: 152px;"/></td>
				<td><input class="btn2" value="搜索" type="button" onclick="serch2();" /></td>
			</tr>
			<tr>
				<td>手术类型：<select id="ser3" name="ser3" style=" width: 152px;">
					        <option value='0'> --全部--</option>
					        <%=sr_type%>
					        </select>
				</td>
				<td>身份证：<input id="ser4" style=" width: 152px;"/></td>
				<td><input class="btn2" value="导出" type="button" onclick="expData();" /></td>
			</tr>
		</table>
   <div id="sur_grid"></div>
   <div id="sur_show_grid"></div>
   <div id="surAdd-div" style="display: none;">
			<form id="sur_add_form" name="sur_add_form">
			    <input type="hidden" id="tbe_id" name="tbe_id" value="" />
				<input type="hidden" id="org_id" name="org_id" value="" />
				<input type="hidden" id="reserve1" name="reserve1" value="" />
				<input type="hidden" id="reserve2" name="reserve2" value="" />
				<input type="hidden" id="reserve3" name="reserve3" value="" />
				<input type="hidden" id="reserve4" name="reserve4" value="" />
				<input type="hidden" id="reserve5" name="reserve5" value="" />
				<input type="hidden" id="tbcsr_type" name="tbcsr_type" value="" />
			      <table class="form_table">
					<tr>
						<td colspan="9" align="left">
							<div style="border-bottom: 1px solid #EBEBEB; font-weight:bold;height: 28px; line-height: 28px;margin: 0 0 5px;" >
								<img src="ligerUI/skins/icons/communication.gif"/>
								<span>四术登记</span>
							</div>
						</td>
					</tr>
					<tr>
					   <td class="form_label"><input style="margin-top: 2px;" type="radio" name="check_type" value="0"  onchange="select_type('1');"/>手术类型：</td>
					   <td><select id="tbcsr_type_1" name="tbcsr_type_1" style=" width: 100px;"  disabled="disabled" onchange="select_type('1');">
					           <option value="109-2">上环</option>
					           <option value="110-1">人流</option>
					           <option value="109-4">取环</option>
					           <option value="109-1">皮埋</option>
					           <option value="109-3">结扎</option>
					           <option value="110-2">引产（中期）</option>
					           <option value="110-3">引产（大月份）</option>
					       </select></td>
					   <td><font color="red">*</font></td>

					   <td class="form_label">手术医院：</td>
					   <td><input class="textbg1" id="tbcsr_hospital" style=" width:180px;" name="tbcsr_hospital" /></td>
					   <td><font color="red">*</font></td>
					</tr>
					<tr>
					   <td></td>
					   <td></td>
					   <td></td>
					   <td class="form_label">手术地点：</td>
					   <td><input class="textbg1" id="tbcsr_place" name="tbcsr_place" style=" width:180px;" /></td>
					   <td><font color="red">*</font></td>
					</tr>
					<tr>
					   <td></td>
					   <td></td>
					   <td></td>

					   <td class="form_label">手术医生：</td>
					   <td><input class="textbg1" id="tbcsr_doctor" name="tbcsr_doctor" style=" width:180px;"/></td>
					   <td><font color="red">*</font></td>
					</tr>
					<tr>
					   <td></td>
					   <td></td>
					   <td></td>

					   <td class="form_label">手术时间：</td>
					   <td><input id="tbcsr_time" name="tbcsr_time" style=" width:180px;"  onkeyup="this.value=formatdata(this.value);"/></td>
					   <td><font color="red">*</font></td>
					</tr>
					<tr>
					   <td></td>
					   <td></td>
					   <td></td>

					    <td class="form_label">术后状况：</td>
					   <td><textarea class="textbg3" cols='23' id="tbcsr_description" name="tbcsr_description" style="height:50px;width:180px;"></textarea></td>
					   <td></td>
					</tr>
					<tr>
					   <td></td>
					   <td></td>
					   <td></td>

					    <td class="form_label">备注：</td>
					   <td ><textarea class="textbg3" cols='23' id="tbcsr_memo" name="tbcsr_memo" style="height:50px;width:180px;"></textarea></td>
					   <td></td>
					</tr>

				 </table>
			</form>
   </div>
   <div id="show_emp" style="display: none;">
		<table class="serTable">
			<tr>
				<td>
					机构：<select id="org3" style=" width: 164px;">
						<%=user.getCurSubOrgOptions()%>
					</select>
				</td>
				<td>姓名：<input id="name3" style=" width: 160px;"/></td>
				<td>身份证：<input id="card3" style=" width: 160px;"/></td>
				<td><input class="btn2" value="搜索" type="button" onclick="serch3();" /></td>
			</tr>
		</table>
		
		<div id="emp-grid"></div>
   </div>
    <div id="survrAdd-div" style="display: none;">
			<form id="survr_add_form" name="survr_add_form">
			    <input type="hidden" id="tbe_id_vr" name="tbe_id_vr" value="" />
			    <input type="hidden" id="tbcsr_id_vr" name="tbcsr_id_vr" value="" />
			    <input type="hidden" id="reserve1" name="reserve1" value="" />
				<input type="hidden" id="reserve2" name="reserve2" value="" />
				<input type="hidden" id="reserve3" name="reserve3" value="" />
				<input type="hidden" id="reserve4" name="reserve4" value="" />
				<input type="hidden" id="reserve5" name="reserve5" value="" />
			      <table class="form_table">
					<tr>
						<td colspan="9" align="left">
							<div style="border-bottom: 1px solid #EBEBEB; font-weight:bold;height: 28px; line-height: 28px;margin: 0 0 5px;" >
								<img src="ligerUI/skins/icons/communication.gif"/>
								<span>随访登记</span>
							</div>
						</td>
					</tr>
							<tr>
					   <td class="form_label">员工姓名：</td>
					   <td><input class="textbg1" id="tbe_name" name="tbe_name" readonly="readonly"/></td>
					   <td></td>
					   <td class="form_label">随访时间：</td>
					   <td><input  id="tbcsrvr_time" name="tbcsrvr_time"  onkeyup="this.value=formatdata(this.value);"/></td>
					   <td><font color="red">*</font></td>
					</tr>
					<tr>
					   <td class="form_label">手术情况：</td>
					   <td><input class="textbg1" id=tbcsr_description_vr name="tbcsr_description_vr" readonly="readonly"/></td>
					   <td></td>
					   <td class="form_label">手术时间：</td>
					   <td><input class="textbg1" id="tbcsr_time_vr" name="tbcsr_time_vr" readonly="readonly"/></td>
					   <td></td>
					</tr>
					<tr>
					   <td class="form_label">术前避孕：</td>
					   <td><input class="textbg1" id="tbcsrvr_surgery_before" name="tbcsrvr_surgery_before" /></td>
					   <td><font color="red">*</font></td>
					   <td class="form_label">术后避孕：</td>
					   <td><input class="textbg1" id="tbcsrvr_surgery_after" name="tbcsrvr_surgery_after" /></td>
					   <td><font color="red">*</font></td>
					</tr>
					<tr>
					   <td class="form_label">月经情况：</td>
					   <td><input class="textbg1" id="tbcsrvr_emmenia" name="tbcsrvr_emmenia"/></td>
					   <td></td>
					   <td class="form_label">产后避孕：</td>
					   <td><input class="textbg1" id="tbcsrvr_offer" name="tbcsrvr_offer"/></td>
					   <td></td>
					</tr>
				 </table>
			</form>
   </div>
  </body>
</html>
